{% extends "index.html" %}
{% block title %}发布新文章{% endblock %}
{% block content %}
    <form class="form-horizontal" method="post" action="{% url 'create' %}" enctype="multipart/form-data">
        {% csrf_token %}
        <div class="form-group">
                <div style="text-align: center"><h2>发布新文章</h2></div>
            </div>
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">标题</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" placeholder="标题" name="title">
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">分类</label>
            <div class="col-sm-10">
                <select class="form-control" name="term">
                    {% for term in term_list %}
                    <option value="{{ term.id }}">{{ term.name }}</option>
                    {% endfor %}
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">简介</label>
            <div class="col-sm-10">
                <textarea class="form-control" rows="3" name="summary"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label" name="content">内容</label>
            <div class="col-sm-10">
                <textarea id="create_bbs" name="content"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">标签</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" placeholder="标签" name="tag">
            </div>
        </div>
        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">文章状态</label>
            <div class="col-sm-10">
                <label class="radio">
                    <input type="radio" name="status" id="inlineRadio1" value="0"> 开放
                </label>
                <label class="radio">
                    <input type="radio" name="status" id="inlineRadio2" value="1"> 关闭
                </label>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-1 col-sm-10">
                <button type="submit" class="btn btn-default">发布</button>
            </div>
        </div>
    </form>
<script src="/static/plugin/tinymce/js/tinymce/tinymce.min.js"></script>
  <script>
        tinymce.init({
            selector: "#create_bbs",
            theme: "modern",
            //width: 300,
            height: 300,
            plugins: [
                 "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
                 "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                 "save table contextmenu directionality emoticons template paste textcolor"
           ],
           //content_css: "css/content.css",
           toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons",
           style_formats: [
                {title: 'Bold text', inline: 'b'},
                {title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
                {title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
                {title: 'Example 1', inline: 'span', classes: 'example1'},
                {title: 'Example 2', inline: 'span', classes: 'example2'},
                {title: 'Table styles'},
                {title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
            ]
        });
  </script>
{% endblock %}